{include file="layout/layout"}
<div class="page">
    <div class="fixed-bar">
        <div class="item-title"><a class="back" href="javascript:history.back();" title="返回列表"><i class="fa fa-arrow-circle-o-left"></i></a>
            <div class="subject">
                <h3>商户系统-提现申请</h3>
                <h5>网站系统申请提现</h5>
            </div>
        </div>
    </div>
    <form class="form-horizontal" method="post" id="add_form" onsubmit="return check_user()" action="{:url('cash/requireCash')}">
        <input type="hidden" name="shop_id" value="1">
        <div class="ncap-form-default">
            <dl class="row">
                <dt class="tit">
                    <label for="nickname"><em>*</em>提现金额</label>
                </dt>
                <dd class="opt">
                    <input type="text" name="money_count" id="nickname" class="input-txt">
                    <span class="err"></span>
                    <p class="notic">(当前账户金额：<span id="check_cash">{$rest}</span>元)</p>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label for="bank"><em>*</em>收款银行</label>
                </dt>
                <dd class="opt">
                    <input type="text" name="bank" id="bank" class="input-txt">
                    <span class="err"></span>
                    <p class="notic">建议填写4大银行（中国银行、中国建设银行、中国工商银行和中国农业银行）请填写详细的开户银行分行名称，虚拟账户如支付宝、微信填写”支付宝“、”微信“即可。</p>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label for="bank_account"><em>*</em>收款账户</label>
                </dt>
                <dd class="opt">
                    <input type="text" name="bank_account" id="bank_account" class="input-txt">
                    <span class="err"></span>
                    <p class="notic">银行账号或虚拟账号（支付宝、微信等账号），微信提现时需要绑定微信账号，收款账号为openid</p>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label for="account_name"><em>*</em>开户人姓名</label>
                </dt>
                <dd class="opt">
                    <input type="text" name="account_name" id="account_name" class="input-txt">
                    <span class="err"></span>
                    <p class="notic">收款账号的开户人姓名</p>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label for="mobile"><em>*</em>验证码</label>
                </dt>
                <dd class="opt">
                    <input type="text" name="agem_phone" id="mobile" class="input-txt">
                    <input type="button" name="verity_check" value="发送验证码" id="verity_check">
                    <span class="err"></span>
                    <p class="notic"></p>
                </dd>
            </dl>
            <div class="bot">
                <input type="submit" value="确认提交" class="ncap-btn-big ncap-btn-green" id="checkUserUpdate">
                &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
                <input type="reset" value="取消返回" onclick="location.href='{:url("cash/cash")}'" class="ncap-btn-big ncap-btn-green" id="checkUserUpdate">
            </div>
        </div>
    </form>
</div>

<script>
     function check_user () {


        var nickname = $('input[name="money_count"]').val();
        var bank = $('input[name="bank"]').val();
        var bank_account = $('input[name="bank_account"]').val();
        var account_name = $('input[name="account_name"]').val();
        var mobile = $('input[name="agem_phone"]').val();
        var check_cash = $('#check_cash').text();

        var error ='';

        if(nickname == ''){
            error += "提现额度不能为空\n";
        }
        if(bank == ''){
            error += "收款银行不能为空\n";
        }
        if(bank_account == ''){
            error += "收款账户不能为空\n";
        }
        if(account_name ==''){
            error += "开户人姓名不能为空\n";
        }
        if(mobile ==''){
            error += "验证码不能为空\n";
        }
        if(eval(nickname) > eval(check_cash)){
            error += "提现金额不能大于当前账户余额\n";
        }


        if(error){
            layer.alert(error, {icon: 2});  //alert(error);
            return false;
        }
        return true;


    };

</script>
<script>
    $('#verity_check').click(function () {

        var shop_id = $('input[name="shop_id"]').val();
        var error ='';
        $.ajax({
            type : 'post',
            url : "{:url('index/cash/smsPhone')}",
            data : {sp_id:shop_id},
            dataType : 'json',
            success : function(data){
                if(data){
                    error+="60秒以后再试";
                    layer.alert(error, {icon: 2});  //alert(error);
                    return false;
                }
                return true;
            }
        })

    });

</script>